package server;

import java.io.IOException;
import java.net.ServerSocket;
import java.util.ArrayList;

public class ServerMain {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		try {
			ServerSocket ss = new ServerSocket(30001);
			ArrayList<Participant> pl = new ArrayList<Participant>();
			ArrayList<ReceiveThread> rtl = new ArrayList<ReceiveThread>();
			ArrayList<SessionThread> stl = new ArrayList<SessionThread>();
			String filename = "wordlist.txt";
			WordListHandeler wlh = new WordListHandeler(filename);
			String[] wordlist = wlh.readFile();
			ReceiveMonitor serverRM = new ReceiveMonitor();
			if (wordlist == null) {
				System.out.println("Unable to read words form the file "
						+ filename + ".\nThe program will now terminate.");
				System.exit(1);
			}
			ServerProgram sp = new ServerProgram(serverRM, pl, rtl, stl, ss,
					wordlist);
			sp.startServer();

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
